<!DOCTYPE html>
<html lang="en">
<head>
    <#include "common/head.ftl">
    <link rel="stylesheet" href="${staticUrl}/css/mockExam.css">
</head>
<body>
<#include "common/header.ftl">
<#assign question_no=1>
<div class="pracontent">
    <div class="examHead bor">
    	<!--得分情况-->
    	<div class="score">
    		<div class="score_num"></div>
    		<div class="score_ico"></div>
    	</div>
        <!--试卷的信息-->
        <h2 class="h2">${title}</h2>
        <div class="info">
            <p>◇ 本卷用于模拟考试,仅供考生练习使用</p>
            <p>◇ 本卷共分为${choiceList?size}个选择题 , ${word?size + excel?size + ppt?size}个操作题</p>
            <p>◇ 本试卷考生提交立即给出答案</p>
        </div>
        <div class="select layui-clear" style="position: relative; z-index: 10">
                <div class="select-sub">
                    <div class="navbox">
                        <#if (!type??) || (type == 'choice')>
                        <a href="javascript:;" id="option"class="layui-btn layui-btn-small layui-btn-danger">选择题</a>
                        </#if>
                        <#if (!type??) || (type == 'word')>
                        <a href="javascript:;" id="word"  class="layui-btn layui-btn-small">Word</a>
                        </#if>
                        <#if (!type??) || (type == 'excel')>
                        <a href="javascript:;" id="excel" class="layui-btn layui-btn-small">Excel</a>
                        </#if>
                        <#if (!type??) || (type == 'ppt')>
                        <a href="javascript:;" id="ppt"   class="layui-btn layui-btn-small">PPT</a>
                        </#if>
                    </div>
                </div>
        </div>
        <div class="drop-con layui-clear">
            <div class="pra-left-con">
                <div id="questionModule">
                	<#if choiceList?? && (choiceList?size>0) >
                    <div class="m_rule">
                        <div class="select-title questionModule">${question_no}、选择题(每小题1分)</div>
                        <#assign question_no= question_no + 1>
                    </div>
                    <ul class="m_select">
                        <#list choiceList as item>
                        <li>
                            <div class="subject-con">
                                <div class="sub-content">
                                    <div class="sub-title"><em>${item_index +1}</em><span>[单选题]</span>${item.title}</div>
                                    <div class="sub-answer">
                                    <i id="result_${item_index}" class="result_answer result_wrong"></i>
                                        <dl class="select_questions">
                                            <dd><input type="radio" name="${item_index}" value="A"><label><span>A.</span>${item.optionA}</label></dd>
                                            <dd><input type="radio" name="${item_index}" value="B"><label><span>B.</span>${item.optionB}</label></dd>
                                            <dd><input type="radio" name="${item_index}" value="C"><label><span>C.</span>${item.optionC}</label></dd>
                                            <dd><input type="radio" name="${item_index}" value="D"><label><span>D.</span>${item.optionD}</label></dd>
                                            
                                        </dl>
                                    </div>
                                    <div class="select_answer layui-clear">
                                        <span id="choice_${item_index}">参考答案 <em class="right" >${item.answer}</em> 您的答案 <em class="youranswer"></em></span>
                                    </div>
                                </div>
                            </div>
                        </li>
                        </#list>
                    </ul>
                    </#if>
					<#if word?? && (word?size>0) >
                    <div class="m_rule">
                        <div class="select-title look_word" >${question_no}、Word处理题</div>
                        <#assign question_no= question_no + 1>
                    </div>
                    <ul class="m_ruleQuest">
                        <#list word as item>
                        <li>
                            <div class="subject-con">
                                <div class="sub-content">
                                    <div class="sub-title">
                                        <em>${item_index +1}</em>
                                        <span>[Word操作题]</span>
                                    </div>
                                    <dl class="sub-answer vsub-con">
                                        <dd>
                                    <p class="oper_tit">请点击以下链接下载素材到本地计算机，然后阅读下面的题目作答。完成后保存并关闭文档，点击题目下方的“上传文件” 按钮提交</p>
                                        </dd>
                                        <div class="download">

                                            <div class="dl_info">
                                                <p><i class="layui-icon">&#xe601;</i>点击按钮，下载试题</p>
                                                ${item.sourceUrl}
                                            </div>
                                        </div>
                                        <dd>
                                        	${item.title}
                                        </dd>
                                        
                                     	<div class="pull_txt">
                                            <input id="input-${item.id}" type="file" style="display:none" accept=".docx"/>
                                            <button id="btn-${item.id}" data-index="word${item_index}" type="button" class="layui-btn bar-btn">
                                                <i class="layui-icon">&#xe67c;</i>上传文件
                                            </button>
                                            <span class="remind"></span>
                                            <div id="progress-${item.id}" class="layui-progress load-bar" lay-showpercent="true">
                                            	<div class="layui-progress-bar" lay-percent="0%"></div>
                                        	</div>
                                        	<span id="remind-${item.id}"></span>
                                        </div>
                                        
                                    </dl>
                                    <div class="remind_answer remind_word" style="display:none">
											<span>文件正在解析，请稍后,还有n个文件待处理</span>
											<div class="error_infor" style="display:none">
											
											<span class="err_info">错误提示</span>
												
												<div class="p-info">
													
												</div>
											</div>
											<div class="answer_info">
												<a href="${staticUrl}/questions/analysis/${item.answer}.html" target="_blank">点击链接查看答案与解析</a>
											</div>
									</div>
                                </div>
                            </div>
                        </li>
                        </#list>
                    </ul>
                    </#if>
                    <#if excel?? && (excel?size>0) >
                    <!--Excel start-->
                    <div class="m_rule">
                        <div class="select-title look_excel" >${question_no}、Excel处理题</div>
                        <#assign question_no= question_no + 1>
                    </div>
                    <ul class="m_ruleQuest">
                        <#list excel as item>
                        <li>
                            <div class="subject-con">
                                <div class="sub-content">
                                    <div class="sub-title">
                                        <em>${item_index +1}</em>
                                        <span>[Excel操作题]</span>
                                    </div>
                                    <dl class="sub-answer vsub-con">
                                        <dd>
                                        	<p class="oper_tit">请点击以下链接下载素材到本地计算机，然后阅读下面的题目作答。完成后保存并关闭文档，点击题目下方的“上传文件” 按钮提交</p>
                                        </dd>
                                        <div class="download">
                                          <div class="dl_info">
                                              <p><i class="layui-icon">&#xe601;</i>点击按钮，下载试题</p>
                                                ${item.sourceUrl}
                                            </div>
                                        </div>
                                        <dd>
                                        	${item.title}
                                        </dd>

                                        <div class="pull_txt">
                                            <input id="input-${item.id}" type="file" style="display:none" accept=".xlsx"/>
                                            <button id="btn-${item.id}" data-index="excel${item_index}" type="button" class="layui-btn bar-btn">
                                                <i class="layui-icon">&#xe67c;</i>上传文件
                                            </button>
                                            <span class="remind"></span>
                                            <div id="progress-${item.id}" class="layui-progress load-bar" lay-showpercent="true">
                                            	<div class="layui-progress-bar" lay-percent="0%"></div>
                                        	</div>
                                        	<span id="remind-${item.id}"></span>
                                        </div>
                                        
                                    </dl>
                                    <div class="remind_answer remind_excel" style="display:none">
											<span>文件正在解析，请稍后,还有n个文件待处理</span>
											<div class="error_infor" style="display:none">
											
											<span class="err_info">错误提示</span>
											
												<div class="p-info">
												</div>
											</div>
											<div class="answer_info">
												<a href="${staticUrl}/questions/analysis/${item.answer}.html" target="_blank">点击链接查看答案与解析</a>
											</div>
									</div>
                                </div>
                            </div>
                        </li>
                        </#list>
                    </ul>
                    </#if>
                    <!--Excel end-->
                    
                    <#if ppt?? && (ppt?size>0) >
                    <!--PPT start-->
                     <div class="m_rule">
                        <div class="select-title look_ppt" >${question_no}、PowerPoint处理题</div>
                        <#assign question_no= question_no + 1>
                    </div>
                    <ul class="m_ruleQuest">
                        <#list ppt as item>
                        <li>
                            <div class="subject-con">
                                <div class="sub-content">
                                    <div class="sub-title">
                                        <em>${item_index +1}</em>
                                        <span>[PPT操作题]</span>
                                    </div>
                                    <dl class="sub-answer vsub-con">
                                        <dd>
                                    <p class="oper_tit">请点击以下链接下载素材到本地计算机，然后阅读下面的题目作答。完成后保存并关闭文档，点击题目下方的“上传文件” 按钮提交</p>
                                        </dd>
                                        <div class="download">
                                            <div class="dl_info">
                                                <p><i class="layui-icon">&#xe601;</i>点击按钮，下载试题</p>
                                                ${item.sourceUrl}
                                            </div>
                                        </div>
                                        <dd>
                                        	${item.title}
                                        </dd>
                                        
                                        <div class="pull_txt">
                                            <input id="input-${item.id}" type="file" style="display:none" accept=".pptx"/>
                                            <button id="btn-${item.id}" data-index="ppt${item_index}" type="button" class="layui-btn bar-btn">
                                                <i class="layui-icon">&#xe67c;</i>上传文件
                                            </button>
                                            <span class="remind"></span>
                                            <div id="progress-${item.id}" class="layui-progress load-bar" lay-showpercent="true">
                                            	<div class="layui-progress-bar" lay-percent="0%"></div>
                                        	</div>
                                        </div>							                                       
                                    </dl>
                                    <div class="remind_answer remind_ppt" style="display:none">
											<span>文件正在解析，请稍后,还有n个文件待处理</span>
											<div class="error_infor" style="display:none">
											<span class="err_info">错误提示</span>
												<div class="p-info">
												</div>
											</div>
											<div class="answer_info">
												<a href="${staticUrl}/questions/analysis/${item.answer}.html" target="_blank">点击链接查看答案与解析</a>
											</div>	
									</div>
                                </div>
                            </div>
                        </li>
                        </#list>
                    </ul>
                    </#if>
                    <!--PPT end-->
                    
                </div>
            </div>
            <div class="pra-right-con">
                <div id="m_rightPart" class="par-right-con-sub bor">
                    <!--右侧区域-->
                    <div class="time-card">
                            <!--倒计时-->
                        <div class="y-time">
                            <div class="time-item">
                                <strong id="hour_show">0时</strong>
                                <strong id="minute_show">0分</strong>
                                <strong id="second_show">0秒</strong>
                            </div>
                        </div>
                        <!--答题卡主要部分-->
                        <div class="rightArea-answer">
                            <div id="answer-card">
                                <div class="hd clearfix">
                                    <div class="title">
                                        答题卡
                                    </div>
                                </div>
                                 <div class="db layui-clear">
                                     <dl class="panel-item">
                                         <dt>选择题<em>(每题1分)</em></dt>
                                         <dd class="panel-order">
                                             <#list choiceList as item>
                                             	<a href="javascript:;" data-id="${item_index}">${item_index + 1}</a>
                                             </#list>
                                         </dd>
                                     </dl>
                                     <dl class="panel-item">
                                         <dt>wrod<em>(每题30分)</em></dt>
                                         <dd class="panel-order">
                                         	<#list word as item>
                                             	<a href="javascript:;" data-index="word${item_index}">${item_index +1}</a>
                                             </#list>
                                         </dd>
                                     </dl>
                                     <dl class="panel-item">
                                         <dt>Excel<em>(每题30分)</em></dt>
                                         <dd class="panel-order">
                                             <#list excel as item>
                                             	<a href="javascript:;" data-index="excel${item_index}">${item_index +1}</a>
                                             </#list>
                                         </dd>
                                     </dl>
                                     <dl class="panel-item">
                                         <dt>PowerPoint<em>(每题20分)</em></dt>
                                         <dd class="panel-order">
                                         	<#list ppt as item>
                                            	<a href="javascript:;" data-index="ppt${item_index}">${item_index +1}</a>
                                            </#list>
                                         </dd>
                                     </dl>
                                 </div>
                            </div>
                            <div class="answer-color">
                                <div class="panel-order-notice">
                                        <em>已做</em>
                                        <i class="doit"></i>
                                        <em>未做</em>
                                        <i></i>
                                </div>
                            </div>
                            <div class="btn-sub">
                                <a href="javascript:;" class="end_test">交卷</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="${staticUrl}/plugins/jquery/jquery-3.2.1.min.js"></script>
<script src="${staticUrl}/plugins/layui/layui.all.js"></script>
<script type="text/javascript">
	layui.use('element', function(){
  		var element = layui.element;
	});
    $(".navbox a").on("click",function () {
        $(this).addClass("layui-btn-danger").siblings().removeClass("layui-btn-danger");
    })
    
    //每隔5分钟发送确认的请求
    
    setInterval(function(){
    	$.get({
    		url:'${rootUrl}'+'/ping'
    	})	
    },60*1000)
    
     function getTop(){
    	if($(".navbox").hasClass("nav-fix"))
    		return 60;
    	return 100;
    	}
	//考试页面的锚点跳转
	function Skip(){
		//根据锚点平滑过渡

	    $("#option").on("click",function () {
	        $('html, body').animate({scrollTop: $('.questionModule').offset().top-90}, 500);
	    });
	    $("#word").on("click",function () {
	    var theTop = getTop();
	        $('html, body').animate({scrollTop: $('.look_word').offset().top-theTop}, 500);
	    });
	    $("#excel").on("click",function () {
	    var theTop = getTop();
	        $('html, body').animate({scrollTop: $('.look_excel').offset().top-theTop}, 500);
	    });
	    $("#ppt").on("click",function () {
	    var theTop = getTop();
	        $('html, body').animate({scrollTop: $('.look_ppt').offset().top-theTop}, 500);
	    });
	}
    
    //获取url中的type值
    
    function GetQueryString(name)
		{
			var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if(r!=null)return unescape(r[2]); return null;
		}
	// 不是考试界面元素的显示
	function choice(){
		var oNavbox = $(".navbox").offset().top;//导航条的top
		var oAnswer = $(".time-card").offset().top;//右侧答题卡加倒计时的top
        var ovtop = $(document).scrollTop();
        if(ovtop>oNavbox){
            $(".navbox").addClass("nav-fix");
        }
        if(ovtop+100 > oAnswer){
            $(".time-card").addClass("time_fixed");
        }
        
        if($(window).height()<670){
            var maxH = $(window).height()-330<0?0:$(window).height()-330;
            $(".rightArea-answer .db").css("max-height",maxH);
          }
          
          $(window).scroll(function () {
            var vtop = $(document).scrollTop();

            if(vtop <= oNavbox && oNavbox <($(window).scrollTop()+$(window).height())){
                $(".navbox").removeClass("nav-fix");
            }else {
                $(".navbox").addClass("nav-fix");
            }

            if( (vtop+100)<= oAnswer && oAnswer<($(window).scrollTop()+$(window).height())){
                $(".time-card").removeClass("time_fixed");
        	}else {
                $(".time-card").addClass("time_fixed");
            }

            
        })
	}

//关于滚动的事件
   $(function () {
   		if(GetQueryString("type") == 'choice'){
   				choice();
   		}else if(GetQueryString("type") == 'word'){
   				choice();
   		}else if(GetQueryString("type") == 'excel'){
   				choice();
   		}else if(GetQueryString("type") == 'ppt'){
   				choice();
   			
   		}else{
   		Skip();
   		var oNavbox = $(".navbox").offset().top;//导航条的top
        var ovtop = $(document).scrollTop();
        var oAnswer = $(".time-card").offset().top;//右侧答题卡加倒计时的top
		var oWord = $(".look_word").offset().top; // word的导航条
		var oExcel = $(".look_excel").offset().top;//excel的导航条
		var oPPt = $(".look_ppt").offset().top;//ppt的导航条*/
		if(ovtop>oNavbox){
            $(".navbox").addClass("nav-fix");
        }
		
        if(ovtop+100 > oAnswer){
            $(".time-card").addClass("time_fixed");
        }
		if(ovtop <= oWord-115){
                $("#option").addClass("layui-btn-danger").siblings().removeClass("layui-btn-danger");
            }else if(ovtop <= oExcel-115){
                $("#word").addClass("layui-btn-danger").siblings().removeClass("layui-btn-danger");
            }else if(ovtop <= oPPt - 115){
            	$("#excel").addClass("layui-btn-danger").siblings().removeClass("layui-btn-danger");
            }else{
            	$("#ppt").addClass("layui-btn-danger").siblings().removeClass("layui-btn-danger");
            }
            if($(window).height()<670){
            var maxH = $(window).height()-330<0?0:$(window).height()-330;
            $(".rightArea-answer .db").css("max-height",maxH);
        }
        $(window).scroll(function () {
            var vtop = $(document).scrollTop();

            if(vtop <= oNavbox && oNavbox <($(window).scrollTop()+$(window).height())){
                $(".navbox").removeClass("nav-fix");
            }else {
                $(".navbox").addClass("nav-fix");
            }

            if( (vtop+100)<= oAnswer && oAnswer<($(window).scrollTop()+$(window).height())){
                $(".time-card").removeClass("time_fixed");
        	}else {
                $(".time-card").addClass("time_fixed");
            }
            
             //滚动条的锚点变化
            if(vtop <= oWord-115){
                $("#option").addClass("layui-btn-danger").siblings().removeClass("layui-btn-danger");
            }else if(vtop <= oExcel-115){
                $("#word").addClass("layui-btn-danger").siblings().removeClass("layui-btn-danger");
            }else if(vtop <= oPPt - 115){
            	$("#excel").addClass("layui-btn-danger").siblings().removeClass("layui-btn-danger");
            }else{
            	$("#ppt").addClass("layui-btn-danger").siblings().removeClass("layui-btn-danger");
            }

            
        })
   		}
   
        

    })
     //处理屏幕height过小的问题
    $(window).resize(function () {
		 $(".rightArea-answer .db").css("max-height",500);
		 
        if($(window).height()<670){
            var maxH = $(window).height()-330<0?0:$(window).height()-330;
            $(".rightArea-answer .db").css("max-height",maxH);
        }
    })



    var intDiff = parseInt(${timeSec});//倒计时总秒数量
	var stopTime = false;
    function timer(intDiff){
        window.setInterval(function(){
            hour=0,
                minute=0,
                second=0;//时间默认值
            if(intDiff > 0){
                day = Math.floor(intDiff / (60 * 60 * 24));
                hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
                minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
                second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
            }
            if (minute <= 9) minute = '0' + minute;
            if (second <= 9) second = '0' + second;
            $('#hour_show').html('<s id="h"></s>'+hour+'时');
            $('#minute_show').html('<s></s>'+minute+'分');
            $('#second_show').html('<s></s>'+second+'秒');
            intDiff--;
            
            if(intDiff == 900){
            	 layer.open({
                    time: 5000, //5s后自动关闭
                    area: ['300px', '180px'],
                    content:'<div style="padding:20px 0 0 20px;color:#000000;font-size: 24px">'+'您还有十五分钟交卷'+'</div>',
                    skin: 'layer-ext-moon'
                });
            }
            
            if(intDiff == 0){
            	stopTime = true;
            	layer.open({
                    area: ['400px', '180px'],
                    content:'<div style="padding:20px 0 0 20px;color:#000000;font-size: 20px">'+'本次考试时间到，系统已为您交卷'+'</div>',
                    skin: 'layer-ext-moon'
            	})
            	$(".end_test").click();
            }
        }, 1000);
    }
    $(function(){
       timer(intDiff);
    });
    
    
	//关于dd的事件委托
    
    $(".select_questions").on("click","dd",function () {
       $(this).children("input:first-child").prop("checked", true);
        var id = $(this).children("input:first-child").attr("name");
		$('.panel-order a[data-id='+id+']').addClass("finish");
        $('.panel-order a[data-id='+id+']').css("background","#b1b6bf");
    })
    
    $(".panel-order ").on("click","a",function () {
       var name =  $(this).attr("data-id");
       if(name){
       var count;
       if($(".navbox").hasClass("nav-fix")){
       	count = 130;
       }else{
       	count = 160;
       }	
       $('html, body').animate({scrollTop: $(".select_questions input[name="+name+"]").offset().top-count}, 500);
       }
    })
    
    
    $(".bar-btn").on("click",function(){
    	var id = $(this).attr("data-index");
    	console.log(id);
    	$('.panel-order a[data-index='+id+']').addClass("finish");
    	$('.panel-order a[data-index='+id+']').css("background","#b1b6bf");
    })


	//自定义进度条
		

	$('.bar-btn').on('click',function(e){
		var obj = e.currentTarget
		var id = obj.id
		var inputId = id.replace('btn','input')
		var index = $(this).attr("data-index");//index  
		index = index.substr(index.length-1,1);
		var inputEle = $('#'+inputId)
		inputEle.unbind('change');
		inputEle.on('change',function(e){
			$(obj).attr('disabled','true')
			$(obj).css('background','grey')
			upload(inputEle,index)
		}) 
		inputEle.click()
	})

    function upload(x,index){
        var file = x[0].files[0];
        var progressId = x.attr('id').replace('input','progress')
        var btnId = progressId.replace('progress','btn')
        
        var progress = $('#'+progressId)
        var btn = $('#'+btnId)
        var span = btn.next();
        console.log(file);
        if(! file){
        	btn.attr("disabled",false);
        	btn.css("background","#009688")
            alert('请选择文件')
            return
        }
        span.text("");
        var form = new FormData()
        form.append('file',file)
        var xhr = new XMLHttpRequest();
        xhr.open("post", '${rootUrl}/api/receiveOptionQuestion?index='+index, true);
        xhr.onload = function () {
        	btn.attr("disabled",false);
        	btn.css("background","#009688")
			x.val("");
            var result = eval('('+xhr.responseText+')');
            console.log(result);
            if(result){
            	
            	setTimeout(function(){
            		progress.css("display","none");
            	},500)
            	
            }
            switch (result['code']){
                case 'success':
                	span.text("上传成功");
                	//把input的value值设置为空
                    break;
                case 'login':
                    
                    break;
                case 'errorFile':
                    span.text(result['msg']);
                    break;
                case 'overSize':
                    span.text(result['msg']);
                    break;
                case 500:
                    span.text(result['msg']);
                    break;
            }

        };
        xhr.upload.addEventListener("progress", function(e){
            progress.css("display","block");
            var load = (e.loaded/e.total*100).toFixed(2) + '%';
           	//progress[0].attr('lay-percent',"10%")
           	console.log(1);
           	progress.css('background-color','#009688');
           	progress.width(load);
           	progress.css('text-align','right')
        	progress.text(load);
        }, false);
        xhr.send(form);
    }
    
    //交卷
    var t = null;
    var option_score ;
    $(".end_test").on('click',function(){
    	var flag = false;
    	if(stopTime){
    		flag = true;
    	}else{
    		var flag = end_submit();
    	}
    		
    	if(flag){
    			end_btn();
    			option_score = option_detail();
				
    			//大题的解析
    			var opera_score = 0;
    			if(t == null){
    				console.log(10000)
    				happy();	
    				t  = setInterval(happy,3000);
    			}			
    			
    	}else{
			//不交卷我也没办法，接着做    	
    	}	    	  	 
    })
    
    function end_btn(){	//交卷的按钮变化
    			$(".end_test").css("background","grey");
				$('.end_test').unbind("click")				
    }
    function end_submit(){//提前交卷的提示
    	var length = $(".panel-order a").length;
    	console.log(length);
    	
    	var finish = $(".finish").length;
    	console.log(finish);
    	
    	var flag = false;
    	var str = "";
    	if(length - finish == 0)
    		str = "您已经全部完成，确认提交吗？";
    	else
    		str =  "您还有"+(length-finish)+"道题没有做，确认提交吗？"
    		flag = confirm(str);
    	return flag;
    }
    function option_detail(){
    		var score = 0;
    		
    	    $(".select_questions dd input:checked").each(function(){
    			var value = $(this).val();
    			var name = $(this).attr("name");
    			$("#choice_"+name+" .youranswer").text(value);
    			var right = $("#choice_"+name+" .right").text();
    			if(right==value){
    				score++;
    				$("#choice_"+name+" .youranswer").addClass("right");
    				$("#result_"+name+"").addClass("result_right").remove("result_wrong");
	
    			}else{
    				$("#choice_"+name+" .youranswer").addClass("wrong");
    			}
    			
    		})
    		
    		$(".select_answer").css("display","block");//选择题选项和结果显示出来
    		$(".result_answer").css("display","block");
    		
    	return  score;
    }
    //get访问数据
    var happy  = function remind_info(){
    var opera_score = 0;//初始化操作题分数
    $.get({
	    		url:'mockExam?operation=score',
	    		dataType:'text',
	    		success:function(resText,status){
	    				
	    				console.log(resText);
	    				var results = JSON.parse(resText);
	    				if(results['code']=='success'){
	    					var arr = results['data'];
	    					for(var i=0; i<arr.length; i++){
	    						if(arr[i].type == 'docx'){
	    						var index = arr[i].index;
	    						var x = arr[i];
	    							if(arr[i].state == 'finish'){//大题完成，得到分数
	    								
	    								var score = finish(x,"word",index);
	    								opera_score += score;
	    							}else{
	    								deal(x,"word",index);
	    							}		
	    						}else if(arr[i].type == 'xlsx'){
	    							var index = arr[i].index;
	    							var x = arr[i];
	    							if(arr[i].state == 'finish'){//大题完成，得到分数
	    								var score = finish(x,"excel",index);
	    								opera_score += score;
	    								
	    							}else{
	    								deal(x,"excel",index);
	    							}
	    					}else if(arr[i].type == 'pptx'){
	    							var index = arr[i].index;
	    							var x = arr[i];
	    							if(arr[i].state == 'finish'){//大题完成，得到分数
	    							
	    								var score = finish(x,"ppt",index);
	    								
	    								opera_score += score;
	    								
	    							}else{
	    								deal(x,"ppt",index);
	    							}
	    						}
	    					}
	    					
	    					stop(t,arr,opera_score);	
	    				}
	    				
	    			}
	    		})
    }
    
    function stop(timer,arr,opera_score){
    var score = 0;
    	for(var i=0; i<arr.length; i++){
    		if(arr[i].state != 'finish')
    			break;
    	}
    	if(i==arr.length){
    		clearInterval(timer);
    		score = option_score + opera_score;
    		console.log(score);
    		$('.score_num').text(score);
    		$('.score_num').css('display','block');
    		$('.score_ico').css('display','block');
    	}
    }
    
    function deal(x,str,index){
    	var queue = x.queue;
	    $($(".remind_"+str+"")[index]).children("span").text("正在处理，在您之前还有"+queue+"个处理文件");
	    $($(".remind_"+str+"")[index]).css("display","block");
    }
    
   function finish(x,str,index){
    	var score  = x.result.score;
	    $($(".remind_"+str+"")[index]).children("span").text("您的分数为"+score+"");
	    var err = x.result.errors;
	    if(err){
	    	$($(".remind_"+str+"")[index]).children("div").css("display","block");
	    	$($(".remind_"+str+"")[index]).children("div").children("div").html("");
	    					}
	    for(var j=0; j<err.length ; j++){
	    		$($(".remind_"+str+"")[index]).children("div").children("div").append("<p>"+(j+1)+"."+err[j]+"</p>");
	    }
	    
	    return score;
    }
</script>
</body>
</html>